package icu.twtool.util

import java.nio.file.Path
import kotlin.io.path.Path
import kotlin.io.path.createDirectory
import kotlin.io.path.notExists

/**
 * @author Wen
 * @since 2022-11-02
 */
object PathUtil {

    /**
     * 获取程序运行路径
     */
    fun home(): Path = Path(System.getProperty("user.dir"))

    /**
     * 获取程序的数据目录
     */
    fun data(): Path = home().resolve("data").apply {
        if (this.notExists())
            createDirectory()
    }

    /**
     * 习题目录
     */
    fun exercise(): Path = data().resolve("exercise").apply {
        if (this.notExists())
            createDirectory()
    }

    /**
     * 答案目录
     */
    fun practice(): Path = data().resolve("practice").apply {
        if (this.notExists())
            createDirectory()
    }

}